package com.vhall.component.framework.core.loader;

import com.vhall.component.framework.common.inner.VhallHandler;
import org.springframework.util.CollectionUtils;

import java.util.Collections;
import java.util.List;

/**
 * 扩展 helper 类
 *
 * @author xiaoliang.wang@vhall.com
 */
@SuppressWarnings("unchecked")
public class ExtensionHelper {

    private ExtensionHelper() {
        throw new IllegalStateException("Utility class");
    }

    /**
     * 获取插件所在的 jar 中的配置文件,从中解析出自定义配置及插件列表
     */
    public static List<CustomerExtension> loadComponentsConfig() {
        ExtensionPluginLoader<VhallHandler> loader = ExtensionPluginLoader.getLoader(VhallHandler.class);
        List<CustomerExtension> configs = loader.getExtensionConfigs();
        return CollectionUtils.isEmpty(configs) ? Collections.emptyList() : configs;
    }

}
